import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {NzMessageService} from "ng-zorro-antd/message";
import {NzModalService} from "ng-zorro-antd/modal";
import {ConfigService} from "../../../shared/services/config.service";
import { LayerService } from './layer.service';

@Component({
    selector: 'app-layer',
    templateUrl: './layer.component.html',
    styleUrls: ['./layer.component.scss']
})
export class LayerComponent implements OnInit {

    layers: any = [];

    visible: boolean = false;


    constructor(public configService: ConfigService, private message: NzMessageService, private layerService: LayerService) {
    }

    ngOnInit(): void {
        this.layers = this.layerService.layers;
    }


    /////////////////以下界面交互/////////////////////
    show() {
        this.visible = true;
    }

    close() {
        this.visible = false;
    }

    compareObject(g1: any, g2: any): boolean {
        return g1 && g2 ? g1._id === g2._id : g1 === g2;
    }

    active(layer) {
        if (!layer.active) {
            this.layerService.active(layer);
        } else {
            this.layerService.deactive(layer);
        }
    }

    label(layer) {
        if (!layer.labeled) {
            this.layerService.label(layer);
        } else {
            this.layerService.unlabel(layer);
        }
    }

    switch(layer) {
        this.layerService.switch(layer);
    }
}
